﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary
{
    /// <summary>
    /// Describes the kind of numbers.
    /// </summary>
    public enum KindOfNumber
    {
        /// <summary>
        /// Natural numbers.
        /// </summary>
        NaturalNumber = 0,
        /// <summary>
        /// Integer.
        /// </summary>
        Integer = 1,
        /// <summary>
        /// Rational numbers.
        /// </summary>
        RationalNumber = 2,
        /// <summary>
        /// Complex numbers. 
        /// </summary>
        ComplexNumber = 3,
        /// <summary>
        /// Quaternion.
        /// </summary>
        Quaternion = 4,
        /// <summary>
        /// Octonion.
        /// </summary>
        Octonion = 5
    }

    /// <summary>
    /// This class represents a mathematical interval.
    /// </summary>
    [Serializable]
    public abstract class Interval : IInterval
    {
        /// <summary>
        /// The start of the interval.
        /// </summary>
        private double start;

        /// <summary>
        /// The end of the interval.
        /// </summary>
        private double end;

        /// <summary>
        /// Initializes a new instance of the <see cref="Interval"/> class.
        /// </summary>
        protected Interval()
        {
            this.start = Double.MinValue;
            this.end = Double.MaxValue;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Interval"/> class.
        /// </summary>
        /// <param name="start">The start of the interval.</param>
        /// <param name="end">The end of the interval.</param>
        protected Interval(double start, double end)
        {
            this.start = start;
            this.end = end;
        }

        /// <summary>
        /// Gets or sets the start of the interval.
        /// </summary>
        /// <value>The start of the interval.</value>
        public double Start
        {
            get { return start; }
            set { start = value; }
        }

        /// <summary>
        /// Gets or sets the end of the interval.
        /// </summary>
        /// <value>The end of the interval.</value>
        public double End
        {
            get { return end; }
            set { end = value; }
        }

        /// <summary>
        /// Determines whether the specified value [is in interval].
        /// </summary>
        /// <param name="value">The value to check.</param>
        /// <returns>
        /// 	<c>true</c> if [the specified value] [is in interval]; otherwise, <c>false</c>.
        /// </returns>
        public virtual bool IsInInterval(double value)
        {
            return false; // ((this.start <= value) && (this.end >= value));
        }

        /// <summary>
        /// Determines whether all array values [are in the interval].
        /// </summary>
        /// <param name="value">The value array.</param>
        /// <returns>
        /// 	<c>true</c> if all array values [are in the interval]; otherwise, <c>false</c>.
        /// </returns>
        public virtual bool IsInInterval(double[] value)
        {
            return false;
        }

        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception>
        public override bool Equals(object obj)
        {
            return ((this.start == ((Interval) obj).Start) && (this.end == ((Interval) obj).End));
        }

        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"/>.
        /// </returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            return base.ToString();
        }
    }
}